/*
    pg_print_version.c
        An example to teach you to write a postgresql's extension.
    Wen Yi
*/
#include "postgres.h"
#include "fmgr.h"
#include "funcapi.h"
#include "utils/builtins.h"
#include <string.h>

PG_MODULE_MAGIC;

PG_FUNCTION_INFO_V1(pg_print_version);

Datum
pg_print_version(PG_FUNCTION_ARGS)
{
    text *version;
    version = (text*)palloc(VARHDRSZ + sizeof(PG_VERSION));
    SET_VARSIZE(version, VARHDRSZ + sizeof(PG_VERSION));
    memmove(VARDATA(version), PG_VERSION, sizeof(PG_VERSION));
    PG_RETURN_TEXT_P(version);
}
